package com.iflytek.education.controller;


import com.iflytek.common.annotation.Anonymous;
import com.iflytek.common.core.domain.AjaxResult;
import com.iflytek.education.domain.EduCourse;
import com.iflytek.education.domain.EduTeacher;
import com.iflytek.education.service.IEduCourseService;
import com.iflytek.education.service.IEduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 会员端首页获取课程及讲师信息
 * @author isahino
 */
@RestController
@RequestMapping("/edu/index")
public class EduIndexController {

    @Autowired
    private IEduCourseService courseService;

    @Autowired
    private IEduTeacherService teacherService;

    /**
     * 查询前八条热门课程,前四条讲师记录
     */
    @Anonymous
    @GetMapping("/findCourseAndTeacher")
    public AjaxResult findCourseAndTeacher() {
        List<EduCourse> courseList = courseService.findHotCourse();
        List<EduTeacher> teacherList = teacherService.findHotTeacher();
        Map<String, Object> map = new HashMap<>(2);
        map.put("courseList", courseList);
        map.put("teacherList", teacherList);
        return AjaxResult.success(map);
    }

}
